<script>
export default {
    data() { return {} },
    mounted() { },
    name: "商户属性",
    props: { item: { type: Object, required: true } },
    components: {},
    methods: {
        toggle(event) {
            // console.log(this.item.id);
            // console.log(event.target.checked);
            // this.$emit("toggle", event);
            this.update(event.target.checked);
        },
        update(s) {
            this.item.status = s ? 1 : 0;
            console.log(this.item);

            this.axios.patch('/merchant/poslist/' + this.item.id + '/', {
                data: { status: s ? 1 : 0 }
            }).then(response => {
                console.log(response.status);
                console.log(response.data);
            }).catch(error => {

            });
        }
    }
}
</script>
<template>
    <tr>
        <td>{{ item.id }}</td>
        <td>{{ item.basename }}</td>
        <td>{{ item.sheng }}</td>
        <td>{{ item.license_number }}</td>
        <td>{{ item.juridical_person }}</td>
        <td>{{ item.telephone }}</td>
        <td>
            <div class="form-check form-switch">
                <input class="form-check-input" type="checkbox" role="switch" :checked="item.status == 1"
                    @change="toggle">
            </div>
        </td>
        <td><button type="button" class="btn btn btn-outline-success btn-sm">查看</button>
        </td>
    </tr>
</template>
<style></style>